<script>
const googleAdsUrl = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'
export default {
  props: {
    isMobile: Boolean,
    collapsed: Boolean
  },
  watch: {
    // 监听菜单的展开和收缩 false为收起来
    collapsed (oldVal, val) {
      if (val) {
        document.getElementById('ads').className = 'business-pro-ad'
      } else {
        document.getElementById('ads').className = 'business-pro-ad-none'
      }
    }
  },
  mounted () {
    // this.load()
  },
  methods: {
    load () {
      if (googleAdsUrl) {
        /* eslint-disable */
        let adsbygoogle = []
        const e = document.createElement('script')
        e.id = '_adsbygoogle_js'
        e.src = googleAdsUrl
        this.$el.appendChild(e)
        setTimeout(() => {
          (adsbygoogle = window.adsbygoogle || []).push({})
        }, 2000)
      }
    }
  },
  render () {
    return <div id='ads' class="business-pro-ad">(商用推荐) 企业级商用版 Admin Pro <p>本分支由daming维护</p></div>;
  }
}
</script>

<style lang="less" scoped>
.business-pro-ad {
  display: block;
  position: fixed;
  background: rgba(255,255,255,0.25);
  left: 0;
  bottom: 0;
  padding: 0 12px;
  height: 48px;
  width: 258px;
  z-index: 99;
  color: #1890ff;
  text-align: center;
}
.business-pro-ad-none {
  display: none;
}
</style>
